css: Don't infloop when parsing broken borders
authorBenjamin Otte <otte@redhat.com>
Wed, 30 Jul 2014 16:23:20 +0000 (18:23 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 31 Jul 2014 08:03:18 +0000 (10:03 +0200)
There was an infinite loop when parsing invalid text after having parsed
a color in the border shorthand. See attached testcase for an example.

gtk/gtkcssshorthandpropertyimpl.c
testsuite/css/parser/Makefile.am
testsuite/css/parser/border-infloop-3.12.css [new file with mode: 0644]
testsuite/css/parser/border-infloop-3.12.errors [new file with mode: 0644]
testsuite/css/parser/border-infloop-3.12.ref.css [new file with mode: 0644]

index 06c20ddcd478bd31376ab7dfc708c0d453799a2f..c81e2c470330ce71b7bded2e3b97eadb6e8cab06 100644 (file)
@@ -353,6 +353,13 @@ parse_border_side (GtkCssShorthandProperty  *shorthand,
         if (values[2] == NULL)
           return FALSE;
       }
+    else
+      {
+        /* We parsed and there's still stuff left?
+         * Pretend we didn't notice and let the normal code produce
+         * a 'junk at end of value' error */
+        break;
+      }
   }
   while (!value_is_done_parsing (parser));
 
index c7754ce39a54b5a21d2827f3c8cfb971c65b9322..f44f7757dc3131798600b6448ffcd5cf7d75fa58 100644 (file)
@@ -178,6 +178,9 @@ test_data = \
        border.ref.css \
        border-color-currentcolor.css \
        border-color-currentcolor.ref.css \
+       border-infloop-3.12.css \
+       border-infloop-3.12.errors \
+       border-infloop-3.12.ref.css \
        border-radius.css \
        border-radius.errors \
        border-radius.ref.css \
diff --git a/testsuite/css/parser/border-infloop-3.12.css b/testsuite/css/parser/border-infloop-3.12.css
new file mode 100644 (file)
index 0000000..62acb3e
--- /dev/null
@@ -0,0 +1,3 @@
+* {
+  border-bottom: tomato dot;
+}
diff --git a/testsuite/css/parser/border-infloop-3.12.errors b/testsuite/css/parser/border-infloop-3.12.errors
new file mode 100644 (file)
index 0000000..808dde3
--- /dev/null
@@ -0,0 +1 @@
+border-infloop-3.12.css:2: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
diff --git a/testsuite/css/parser/border-infloop-3.12.ref.css b/testsuite/css/parser/border-infloop-3.12.ref.css
new file mode 100644 (file)
index 0000000..e69de29